package org.example.sudoku.database;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import static org.example.sudoku.database.ConstantsDB.KEY_GAME;
import static org.example.sudoku.database.ConstantsDB.KEY_DESCRIPTION;
import static org.example.sudoku.database.ConstantsDB.KEY_ROWID;
import static org.example.sudoku.database.ConstantsDB.KEY_DIFICULTY;
import static org.example.sudoku.database.ConstantsDB.DB_TABLE;

public class SudokuTable {

	private static final String DATABASE_CREATE=
			String.format("CREATE TABLE %s ( %s INTEGER PRIMARY KEY AUTOINCREMENT, %s TEXT NOT NULL, %s TEXT NOT NULL,%s TEXT )",//NOT NULL)
					DB_TABLE,KEY_ROWID,KEY_GAME,KEY_DIFICULTY,KEY_DESCRIPTION);
	/*"CREATE TABLE todo " + DB_TABLE+
			"(_id INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_ROWID+
			" category TEXT NOT NULL," +KEY_CATEGORY+
			"summary TEXT NOT NULL" +KEY_SUMMARY+
			"description TEX NOT NULL);"+KEY_DESCRIPTION;*/
	
	public static void onCreate(SQLiteDatabase database ) {
	database.execSQL(DATABASE_CREATE);
	}
	
	public static void onUpgrade(SQLiteDatabase database, int oldVersion,int newVersion){
		
		Log.w(SudokuTable.class.getName(),String.format( "Upgrading database from version %d to %d" +
				"which will destroy all old data",oldVersion,newVersion )
				);
		database.execSQL("DROP TABLE IF EXISTS todo");
		onCreate(database);
	}
	
}
